package com.mall.goods.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mall.goods.mapper.PmsProductAttributeCategoryMapper;
import com.mall.model.domain.PmsProductAttributeCategory;
import com.mall.model.vo.CommonPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class PmsProductAttributeCategoryService {
    @Autowired(required = false)
    private PmsProductAttributeCategoryMapper productAttributeCategoryMapper;
    
    /**
     * 分页获取所有商品属性分类
     */
    public CommonPage list(Integer pageNum, Integer pageSize) {
        Page<PmsProductAttributeCategory> page = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<PmsProductAttributeCategory> qw = new LambdaQueryWrapper<>();
//        qw.orderByAsc(PmsProductAttributeCategory::getSort);

        Integer count = productAttributeCategoryMapper.selectCount(qw);
        productAttributeCategoryMapper.selectPage(page, qw);
        return new CommonPage(pageNum, pageSize, count, page.getRecords());
    }
}
